#pragma once
#include "RBTree.h"

namespace wjy
{
	template<class K>
	class set
	{
	public:
		struct SetKeyOfT
		{
			const K& operator()(const K& k)
			{
				return k;
			}
		};

		typedef typename RBTree<K, K, SetKeyOfT>::iterator iterator;

		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

		pair<iterator,bool> Insert(const K& key)
		{
			return _t.Insert(key);
		}

		iterator find(const K& key)
		{
			return _t.Find(key);
		}
	private:
		RBTree<K, K,SetKeyOfT> _t;
	};

	void test_set()
	{
		set<int> s;
		s.Insert(1);
		s.Insert(4);
		s.Insert(6);
		s.Insert(14);
		s.Insert(2);

		set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		for (auto e : s)
		{
			cout << e << " ";
		}
		cout << endl;

		set<int> copy(s);
		for (auto e : copy)
		{
			cout << e << " ";
		}
		cout << endl;
	}
}